﻿using System.Drawing;

using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using System;

namespace Space_Conquest
{
    /// <summary>
    /// Holds the actual Bitmap File to Render
    /// </summary>
    class Texture
    {
        
        public Microsoft.DirectX.Direct3D.Texture mTexture;
        private Bitmap mBitmap;

        public Texture(string Filename)
        {

            try
            {
                mBitmap = new Bitmap(Globals.RESOURCE_DIRECTORY + Filename);
            }
            catch
            {
                #if DEBUG
                Helpers.LogEvent("Space_Conquest.Texture (Framework/Texture.cs)", "Could not find image file: " + Filename);
                #endif

                mBitmap = new Bitmap(Globals.RESOURCE_DIRECTORY + "Images/Missing.bmp");
            }
    
            mBitmap.MakeTransparent(Color.Blue);
            mTexture = new Microsoft.DirectX.Direct3D.Texture(Globals.device, mBitmap, 0, Pool.Managed);

        }

        public int Width
        {
            get
            {
                return mBitmap.Width;
            }
        }

        public int Height
        {
            get
            {
                return mBitmap.Height;
            }
        }

        ~Texture()
        {

            mTexture.Dispose();
            mBitmap.Dispose();

            mTexture = null;
            mBitmap = null;

        }


    }
}
